/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mascotikas.client.animals;

/**
 *
 * @author aneira
 */
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceImageField;
import com.smartgwt.client.data.fields.DataSourceTextField;

public class AnimalIndexXmlDs extends DataSource {

    private static AnimalIndexXmlDs instance = null;

    public static AnimalIndexXmlDs getInstance() {
        if (instance == null) {
            instance = new AnimalIndexXmlDs("animalIndexDS");
        }
        return instance;
    }

    public AnimalIndexXmlDs(String id) {

    //    setID(id);
        setRecordXPath("/List/Object");
        DataSourceTextField commonNameField = new DataSourceTextField("commonName", "Animal");
        DataSourceImageField pictureField = new DataSourceImageField("picture", "Picture");
        pictureField.setImageURLPrefix("animals/");
        setFields(commonNameField, pictureField);
        setDataURL("ds/animals.index.xml");
        setClientOnly(true);
    }

    /**
     * Override transformRequest. Here for illustration purposes only and this override implementation simply calls
     * super.transformReRequest
     *
     * @param dsRequest the DSRequest being processed
     * @return the transformed request
     */
    @Override
    protected Object transformRequest(DSRequest dsRequest) {
        return super.transformRequest(dsRequest);
    }
}
